<div class="layui-layout layui-layout-admin">
  <div class="layui-header" id="app-header">
    <script
      type="text/html"
      template
      lay-done="layui.element.render('nav','nepadmin-header')"
    >
      <ul class="layui-nav layui-layout-left" lay-filter="nepadmin-header">
          <li class="layui-nav-item" lay-unselect>
              <a nepadmin-event="flexible" title="侧边伸缩">
                  <i class="layui-icon layui-icon-shrink-right"></i>
              </a>
          </li>

          <li class="layui-nav-item layui-hide-xs" lay-unselect>
              <a nepadmin-event="prev" title="返回上一页">
                  <i class="layui-icon layui-icon-prev"></i>
              </a>
          </li>
          <li class="layui-nav-item layui-hide-xs" lay-unselect>
              <a nepadmin-event="refresh" title="刷新" onclick="layui.view.tab.refresh()">
                  <i class="layui-icon layui-icon-refresh-3"></i>
              </a>
          </li>

          <!-- <li class="layui-nav-item layui-hide-xs" lay-unselect>
              <input type="text" placeholder="Search / 搜索 ..." autocomplete="off" class="layui-input layui-search-input" nepadmin-event="serach">
          </li> -->
      </ul>
      <ul class="layui-nav layui-layout-right" lay-filter="nepadmin-header">

          <!-- <li class="layui-nav-item layui-hide-xs" lay-unselect>
              <a nepadmin-event="fullscreen" title="切换全屏">
                  <i class="layui-icon layui-icon-screen-full"></i>
              </a>
          </li>
          <li class="layui-nav-item layui-hide-xs" lay-unselect>
              <a title="APP 下载" lay-popup="{url:'popup/phone','offset':'rt',area:['400px','100%'],anim:5}">
                  <i class="layui-icon layui-icon-cellphone"></i>
              </a>
          </li> -->

          <li class="layui-nav-item" lay-unselect>
              <a class="layui-hide-xs">
                  欢迎回来，{{ layui.admin.data()['user'].deptName }} - {{layui.admin.data()['user'].userName  }}
                  <i class="layui-icon layui-icon-triangle-d"></i>
              </a>
              <a class="layui-hide-sm layui-show-xs-inline-block">
                  <i class="layui-icon layui-icon-username"></i>
              </a>
              <dl class="layui-nav-child">
                  <dd><a href="javascript:void(0);" onclick="updatepwd()">修改密码</a></dd>
                  <hr/>
                  <dd><a href="javascript:void(0);" onclick="outlog()">退出登录</a>
                      <div style="display:none;"><a id="out" href="javascript:void(0);" nepadmin-event="logout"></a></div></dd>
              </dl>
          </li>
      </ul>
    </script>
  </div>

    <div class="layui-card" id="pwd_edit" style="display: none;">
        <div class="layui-card-body layui-row layui-col-space10">
            <div class="layui-card-body" style="padding: 15px;text-align: center;">
                <form class="layui-form" action="" lay-filter="form-pwd">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label"><span class="xing">*</span>原密码:</label>
                            <div class="layui-input-inline">
                                <input type="password" name="oldPwd" placeholder="原密码" lay-verify="required" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label"><span class="xing">*</span>新密码:</label>
                            <div class="layui-input-inline">
                                <input type="password" name="newPwd" placeholder="新密码" lay-verify="required" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label"><span class="xing">*</span>确认新密码:</label>
                            <div class="layui-input-inline">
                                <input type="password" name="realNewPwd" placeholder="确认新密码" lay-verify="required" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="form-pwd-submit">确认修改</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!--客户管理销户清账时 跳转缴费工作台使用 -->
    <div hidden>
        <input type="hidden" id="recharge_customer_id_hidden" name="recharge_customer_id_hidden"/>
        <input type="hidden" id="recharge_meter_id_hidden" name="recharge_meter_id_hidden"/>
    </div>

    <div class="nepadmin-tabs-hidden">
    <script type="text/html" id="TPL-app-tabsmenu" template>
      {{# if(layui.conf.viewTabs == true){ }}
      <div class="nepadmin-tabs-wrap">
          <span class="nepadmin-tabs-btn nepadmin-tabs-action nepadmin-tabs-prev" data-type="prev">
              <i class="layui-icon layui-icon-left"></i>
          </span>
          <span class="nepadmin-tabs-btn nepadmin-tabs-action nepadmin-tabs-next" data-type="next">
              <i class="layui-icon layui-icon-right"></i>
          </span>
          <span class="nepadmin-tabs-btn nepadmin-tabs-action nepadmin-tabs-down" data-type="down">
              <i class="layui-icon layui-icon-close"></i>
          </span>
          <ul class="nepadmin-tabs-menu">
              {{# layui.each(layui.view.tab.data,function(i,item){ }}<li data-type="page" class="nepadmin-tabs-btn" lay-url="{{item.fileurl}}"><i class="nepadmin-tabs-ball"></i>{{ item.title }}<b class="layui-icon layui-icon-close nepadmin-tabs-close"></b></li>{{# }) }}
          </ul>
      </div>
      {{# } }}
    </script>
  </div>

  <!-- 侧边菜单 -->
  <div class="layui-side" id="app-sidebar">
    <div class="layui-side-scroll">
      <div class="layui-logo">
        <span>YZ<b>GY</b>-<b>OA</b></span>
      </div>
      <script
        type="text/html"
        template
        lay-api="getMenu"
        lay-done="layui.element.render('nav','nepadmin-sidebar');layui.admin.sidebarFocus()"
      >
        <ul class="layui-nav layui-nav-tree" lay-filter="nepadmin-sidebar" >
            {{#
                function __createSlidebar(data,index){
                    if(!data || data.length == 0) return '';
                    var html = '<dl class="layui-nav-child">';
                    layui.each(data,function(i,child){
                        html += '<dd><a style="padding-left:'+(index == 0 ? 50 : 50 + index * 20)+'px" target="'+(child.target||'')+'" lay-href="'+ (child.url||'') +'" id="'+ (child.sort||'') +'"><span class="layui-icon ' + child.icon +'"></span>' + child.title + '</a>';
                        if(child.childs) html += __createSlidebar(child.childs,index+1);
                        html += '</dd>';
                    });
                    html = html +'</dl>';
                    return html;
                }
                layui.each(d,function(i,child){
            }}
            <li class="layui-nav-item">
                <a lay-href="{{child.url||''}}" target="{{child.target||''}}" title="{{child.title}}"><i class="layui-icon {{child.icon}}"></i>{{child.title}} {{# if(child.notice){ }}<span class="layui-badge">{{ child.notice }}</span>{{# } }}</a>
                {{ __createSlidebar(child.childs,0) }}
            </li>
            {{# }) }}
        </ul>
      </script>
    </div>
  </div>

  <!-- 主体内容 -->
  <div class="layui-body" id="app-body"></div>
</div>
<script>
    layui.use(['admin', 'form', 'jquery',"md5"], function (admin, form,md5, $) {
        var form = layui.form,
            $ = layui.$,
            admin = layui.admin,
            index;
        var md5 = md5;
        window.updatepwd =function (){
            index = layer.open({
                type: 1
                ,anim: 5
                ,shade: 0
                ,maxmin: false
                ,area:['600px','400px']
                ,title:'修改密码'
                ,content: $('#pwd_edit')
            });
        };
        window.outlog =function (){
            layer.alert("是否退出登录？", {
                time: 0 //不自动关闭
                ,btn: ['确定','取消']
                ,yes: function(index){
                    layer.close(index);
                    $("#out").click();
                }
            });
        };

        /* 监听提交 */
        form.on('submit(form-pwd-submit)', function (data) {
            if(data.field.newPwd != data.field.realNewPwd){
                layer.msg("两次密码输入不一致！");
                return false;
            }
            else if(data.field.newPwd.length>=6){
                admin.put({
                    api: "updatePwd",
                    data:{
                        "oldpwd": layui.md5(layui.md5(data.field.oldPwd) + "scgngms0.01"),
                        "newpwd": layui.md5(layui.md5(data.field.newPwd) + "scgngms0.01"),
                        "realnewpwd": layui.md5(layui.md5(data.field.realNewPwd) + "scgngms0.01")
                    },
                    //请求成功
                    success:function(res){
                        if(res.code=="2000"){
                            layer.alert("密码修改成功，请重新登录", {
                                time: 0 //不自动关闭
                                ,btn: ['确定']
                                ,yes: function(index){
                                    layer.close(index);
                                    $("#out").click();
                                }
                            });
                        }
                        else{
                            layer.msg(res.data);
                        }
                    }
                });
                return false;
            }
            layer.msg("密码长度不能小于6位数！");
            return false;
        });
    })
</script>
